<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title></title>
	<script type="text/javascript" src="ajax.js"></script>
</head>
<body>
	用户：<input type="text" id="user" value=""><br/>
	密码：<input type="text" id="pass" value=""><br/>
	<input type="button" id="reg_btn" value="注册">
	<input type="button" id="login_btn" value="登录">
	<script type="text/javascript">
		var user = document.getElementById('user')
		var pass = document.getElementById('pass')
		var reg_btn = document.getElementById('reg_btn')
		var login_btn = document.getElementById('login_btn')
		reg_btn.onclick = function(){
			// alert('d')
			ajax({
				url: '/user',
				type: 'get',
				data: {
					act: 'reg',
					user: user.value,
					pass: pass.value,
				},
				success: function(data){
					console.log(data) 
					var data = eval('('+data+')')

					// console.log(data)
					if(data.ok){
						alert(data.msg)
					}else{
						alert(data.msg)
					}
				}
			})
		}
	</script>
</body>
</html>